//
//  GCHomeCollectionViewCell.m
//  GoldChampion
//
//  Created by Mac on 2018/4/12.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "GCHomeCollectionViewCell.h"
@interface GCHomeCollectionViewCell()

@end
@implementation GCHomeCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self configSubView];
    }
    return self;
}
#pragma mark --subView
- (void)configSubView{
    
    
    self.bannerImageView = [UIImageView new];
    [self addSubview:self.bannerImageView];
    [self.bannerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.left.equalTo(self);
        make.width.equalTo(self);
        make.bottom.equalTo(self).offset(-40);
    }];
    self.bannerImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.bannerImageView.clipsToBounds = YES;
    self.bannerImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onSelctedImageView)];
    [self.bannerImageView addGestureRecognizer:tap];
    
    
    self.iconImageView = [UIImageView new];
    self.iconImageView.clipsToBounds = YES;
    self.iconImageView.layer.cornerRadius = 20;
    [self addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.top.equalTo(self.bannerImageView.mas_bottom).offset(-20);
        make.width.mas_equalTo(40);
        make.height.mas_equalTo(40);
    }];
   

    
    
    self.goodButton = [[STButton alloc] initWithFrame:CGRectZero
                                                     title:@"2424"
                                                titleColor:SecendTextColor
                                                 titleFont:12
                                              cornerRadius:0
                                           backgroundColor:nil
                                           backgroundImage:nil
                                                     image:[UIImage imageNamed:@"关注99"]];
    self.goodButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    self.goodButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 10);
    [self addSubview:self.goodButton];
    
    [self.goodButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-5);
        make.top.equalTo(self.bannerImageView.mas_bottom);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(25);
    }];
    
    

    
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)
                                                     text:@"美好的一天"
                                                textColor:[UIColor whiteColor]
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentCenter];
    self.titleLable.backgroundColor = [FlatBlack colorWithAlphaComponent:0.4];
    [self addSubview:self.titleLable];
    [self.titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self);
        make.centerY.equalTo(self.bannerImageView.mas_centerY);
        make.height.mas_equalTo(25);
    }];
    
}

- (void)setModel:(GCItemModel *)model{
    _model = model;
    [self.bannerImageView sd_setImageWithURL:[NSURL URLWithString:model.img]];
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.img]];
}
- (void)onSelctedImageView{
    if (self.imageViewSelectedHandle) {
        self.imageViewSelectedHandle(self.bannerImageView);
    }
}
@end
